// 采购单相关
import request from "@/utils/request.js";

// 通过id查询采购单
export function getPurchaseById(id){
    return request({
        url: `/ware/purchase/info/${id}`,
        method: 'get'
    });
}

// 新增采购单
export function savePurchase(data){
    return request({
        url: '/ware/purchase/save',
        method: 'post',
        data: data
    });
}

// 更新采购单
export function updatePurchase(data){
    return request({
        url: '/ware/purchase/update',
        method: 'post',
        data: data
    });
}

// 删除采购单
export function deletePurchase(ids){
    return request({
        url: '/ware/purchase/delete',
        method: 'post',
        data: ids
    });
}

// 查询采购单集合
export function getPurchaseList(params){
    return request({
        url: '/ware/purchase/list',
        method: 'get',
        params: params
    });
}

// 查询没有被领取的采购单
export function getPurchaseUnReceiveList(params = {page: 1, limit: 99}){
    return request({
        url: '/ware/purchase/unreceive/list',
        method: 'get',
        params: params
    });
}

// 合并采购需求
export function mergePurchaseDetail(data){
    return request({
        url: '/ware/purchase/merge',
        method: 'post',
        data: data
    });
}



// =========================================== 采购需求 ====================================
// 获取采购需求集合
export function getPurchaseDetailList(params){
    return request({
        url: '/ware/purchasedetail/list',
        method: 'get',
        params: params
    });
}

// 获取采购需求
export function getPurchaseDetailInfo(id){
    return request({
        url: `/ware/purchasedetail/info/${id}`,
        method: 'get'
    });
}

// 保存采购需求
export function savePurchaseDetail(data){
    return request({
        url: '/ware/purchasedetail/save',
        method: 'post',
        data: data
    });
}

// 修改采购需求
export function updatePurchaseDetail(data){
    return request({
        url: '/ware/purchasedetail/update',
        method: 'post',
        data: data
    });
}

// 删除采购需求
export function deletePurchaseDetail(ids){
    return request({
        url: '/ware/purchasedetail/delete',
        method: 'post',
        data: ids
    });
}

